#
#   SEGA SATURN Graphic library make file for GNU

# macro
CC = gcc
LD = ld
RM = deltree
CONV = objcopy

# directory
SGLDIR = /saturn/library/sgl2
SBLDIR = /saturn/library/sbl6/segalib
SBLIDR = $(SBLDIR)/include
SGLIDR = $(SGLDIR)/inc
SGLLDR = $(SGLDIR)/lib
SBLLDR = $(SBLDIR)/lib

CMNDIR = .

GCCDIR = /saturn/program/gnutools
GCCIDR = $(GCCDIR)/include
GCCLDR = $(GCCDIR)/lib

# option
#CCFLAGS = -O2 -m2 -g -c -I$(GCCIDR) -I$(SGLIDR)
CCFLAGS =  -O0 -m2 -g -c -I$(GCCIDR) -I$(SGLIDR) -I$(SBLIDR)
LDFLAGS = -T$(LDFILE) -Map $(MPFILE) -e ___Start
DFLAGS = 
# source_program
include ./objects

TARGET   = sl.coff
TARGET1  = sl.bin
LDFILE   = $(CMNDIR)/$(TARGET:.coff=.lnk)
MPFILE   = $(TARGET:.coff=.map)
MAKEFILE = Makefile

all: $(TARGET) $(TARGET1) test.dat

$(TARGET) : $(OBJS) $(LIBS) $(MAKEFILE) $(LDFILE)
	$(LD) $(LDFLAGS) $(OBJS) $(LIBS) -o $@

$(TARGET1) : $(OBJS) $(LIBS) $(MAKEFILE) $(LDFILE)
	$(CONV) -O binary $(TARGET) $(TARGET1)

texture.c:	test.dat

test.dat:	test.tga tile.tga land0.tga ball.tga
	bgcon test.bgc


# suffix
.SUFFIXES: .asm

.c.o:
	$(CC) $< $(DFLAGS) $(CCFLAGS) -o $@
#	$(CC) $< $(DFLAGS) $(CCFLAGS)
#	as -ahld $*.s > $*.mix

clean:
	$(RM) $(OBJS) $(TARGET:.coff=.*)

